/**
 * @param {string} s
 * @return {number}
 */
 var minimumDeletions = function(s) {
  if(s.length==1) return 0
  let leftb=0,righta=0,ans=0
  for(const c of s){
    if(c=='a') righta++
  }
  ans = righta
  for( const c of s){
    if(c=='a')righta--
    else leftb++
    ans = Math.min(ans,leftb+righta)
  }
  return ans

};